package tests.lucene.filter;

import java.io.IOException;
import java.io.StringReader;
import java.util.StringTokenizer;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.UpperCaseFilter;
import org.apache.lucene.analysis.shingle.ShingleAnalyzerWrapper;
import org.apache.lucene.analysis.shingle.ShingleFilter;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.util.Version;

public class FilterSample {

	public FilterSample() {
	}

	public static void main(String[] args) throws IOException {

		Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_47);
		String theSentence = "You thought that it would be easy, from the very start ,Now I've found you out,I don't think you're so smart";//itr.nextToken();
		StringReader reader = new StringReader(theSentence);
		TokenStream tokenStream = analyzer.tokenStream("content",
				reader);

		UpperCaseFilter theFilter = new UpperCaseFilter(Version.LUCENE_47,tokenStream);
		CharTermAttribute charTermAttribute = theFilter.addAttribute(CharTermAttribute.class);
		theFilter.reset();

		while (theFilter.incrementToken()) {
			System.out.println(charTermAttribute.toString());
		}
		theFilter.end();
		theFilter.close();
		analyzer.close();
	}

}
